//
//  AppDelegate+Extendion.m
//  OASystem
//
//  Created by zhoupengfei on 15/11/22.
//  Copyright © 2015年 zpf. All rights reserved.
//

#import "AppDelegate+Extendion.h"

@implementation AppDelegate (Extendion)
-(void)dismissKeyBoard{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addGestureAction) name:UIKeyboardDidShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenKeyboard) name:UIKeyboardWillHideNotification object:nil];
    
}

-(void)addGestureAction{

    [self.window addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)]];
}

-(void)hiddenKeyboard{
    
    for (UIGestureRecognizer * gesture in self.window.gestureRecognizers) {
        [self.window removeGestureRecognizer:gesture];
    }
}

-(void)dismiss{
    [self.window endEditing:YES];
    for (UIGestureRecognizer * gesture in self.window.gestureRecognizers) {
        [self.window removeGestureRecognizer:gesture];
    }

}

-(void)dealloc{

    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
